<template>
  <div class="daily">
    <div class="top" v-if="obj">
      <h1>
        <span @click="goBack"><van-icon name="arrow-left" /></span
        ><span>{{ obj[0].ar.map((item1) => item1.name).join(",") }}</span>
      </h1>
    </div>
    <h3 v-if="obj">
      Hi云村村民13333..., 快来欣赏
      <span>{{ obj[0].ar.map((item1) => item1.name).join(",") }}</span> 的歌pa
    </h3>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="---我是有底线的---"
      @load="onLoad"
    >
      <van-grid :gutter="1" :column-num="3">
        <van-grid-item
          v-for="item in artistList"
          :key="item.id"
          class="VantGrid"
          @click="Song(item.id)"
        >
          <img :src="item.al.picUrl" alt="a" />
          <p>{{ item.al.name }}</p>
        </van-grid-item>
      </van-grid>
    </van-list>
    <!--    <div v-for="item in videoList" :key="item.data.durations" >-->
    <!--     <iframe height=498 width=510 :src='item.data.scm' frameborder=0></iframe>-->
    <!--    </div>-->
    <div class="ifRame" v-if="url">
      <iframe
        ref="playauto"
        frameborder="no"
        border="0"
        width="100%"
        height="86"
        :src="url"
      ></iframe>
    </div>
  </div>
</template>

<script>
import { getArtistSong } from "../../../api/find";
import { mapActions } from "vuex";
export default {
  name: "Daily",
  data() {
    return {
      id: "",
      artistList: [],
      loading: false,
      finished: false,
      obj: null,
      songId: "",
      url: "",
    };
  },
  created() {
    this.id = this.$route.query.id;
    // console.log(this.id);
    this.handlerArtist(this.id);
  },
  methods: {
    async handlerArtist(id) {
      let params = {
        id,
      };
      this.loading = true;
      const res = await getArtistSong(params);
      // console.log(res);
      this.loading = false;
      this.artistList = res.data.songs;
      // console.log(this.artistList);
      this.obj = res.data.songs;
      // console.log(this.obj);
    },
    onLoad() {
      // setTimeout(() =>(
      //         this.handlerArtist(this.id)
      // ),500)
    },
    goBack() {
      this.$router.push("/find");
    },
    ...mapActions({
      setSongid: "songID/setAsyncid",
    }),
    Song(id) {
      // alert(id)
      // this.songId = id
      this.setSongid(id);
      this.url =
        "//music.163.com/outchain/player?type=2&height=66&id=" +
        this.$store.state.songID.songid;
      // console.log(this.url)
    },
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
.ifRame {
  width: 100%;
  height: 0.6rem;
  background-color: #fff;
}
iframe {
  position: fixed;
  bottom: -0.2rem;
  left: 0;
}
.VantGrid img {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 0.2rem;
}
.VantGrid p {
  width: 1.7rem;
  font-size: 0.14rem;
  margin: 0.08rem 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.van-icon__image {
  width: 0.6rem;
  height: 0.6rem;
}
h3 {
  font-size: 0.34rem;
  font-weight: 400;
  margin: 0.5rem 0 0.2rem 0.1rem;
}
h3 span {
  font-weight: 700;
}
.van-tabs__line {
  position: absolute;
  bottom: 30px;
  left: 0;
  z-index: 1;
  width: 40px;
  height: 5px;
  background-color: #ee0a24;
  border-radius: 3px;
  opacity: 0.3;
}
.top h1 {
  line-height: 1;
  margin: 0.3rem 0.1rem;
}
.top h1 span {
  font-size: 0.4rem;
}
.top h1 span:first-child {
  position: fixed;
  margin-left: 0.2rem;
  font-size: 0.5rem;
}
.top h1 span:last-child {
  width: 100%;
  display: block;
  text-align: center;
}
</style>
